//
//  BCStuffFootView.m
//  BangcaiSale
//
//  Created by lsy on 16/7/14.
//  Copyright © 2016年 Bangcai. All rights reserved.
//

#import "BCStuffFootView.h"

@interface BCStuffFootView ()
{
    UILabel *amountLab;
    UIImageView *logImgV;
}

@end

@implementation BCStuffFootView

-(void)createView{
    self.backgroundColor = BangcaiBlue;
    logImgV = [[UIImageView alloc] initWithImage:self.logoImg];
    amountLab = [[UILabel alloc] init];
    amountLab.backgroundColor = [UIColor colorWithRed:0.999  green:0.241  blue:0.241 alpha:1];
    amountLab.layer.cornerRadius = 10;
    amountLab.layer.masksToBounds =YES;
    amountLab.hidden = YES;
    amountLab.textAlignment = NSTextAlignmentCenter;
    amountLab.textColor = [UIColor whiteColor];
    amountLab.font = [UIFont systemFontOfSize:12];
    self.coomit = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.coomit setTintColor:[UIColor whiteColor]];
    [self.coomit setTitle:@"确认添加" forState:UIControlStateNormal];
    self.coomit.backgroundColor = [UIColor colorWithRed:1  green:0.559  blue:0.046 alpha:1];
    [self addSubview:logImgV];
    [self addSubview:amountLab];
    [self addSubview:self.coomit];
    
    [self getView];
}

- (void)getView{

    [logImgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.bottom.mas_equalTo(-8);
        make.size.and.height.mas_equalTo(57);
        
    }];
        [amountLab mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.width.and.height.mas_equalTo(20 * wx);
        make.bottom.mas_equalTo(-45);
        make.left.mas_equalTo(logImgV.mas_left).with.offset(36);
    }];
    
    [self.coomit mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.and.right.and.bottom.mas_equalTo(0);
        make.width.mas_equalTo(SCREEN_WIDTH / 2 );
    }];
    

}

- (void)setAmount:(NSInteger)amount
{
    _amount = amount;
    amountLab.text = [NSString stringWithFormat:@"%ld", (long)amount];
    if (amount <= 0) {
        amountLab.hidden = YES;
        self.logoImg = [UIImage imageNamed:@"购物车1"];
    }else{
        amountLab.hidden = NO;
        self.logoImg = [UIImage imageNamed:@"购物车"];

    }
}

- (void)setLogoImg:(UIImage *)logoImg
{
    _logoImg = logoImg;
    [logImgV setImage:logoImg];
}

@end
